package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.service.UserPrivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/priviledge/voc/non")
public class UserPriviledgeVocNonController {
    @Autowired
    UserPrivilegeService userPrivilegeService;

    // 两个接口都是content-type: application/x-www-form-urlencoded;
    // 请求体中：   vocId=1851796346740875266
    @PutMapping("cancel")
    public Result cancelNonRecite(Long vocId){
        long userId = StpKit.USER.getLoginIdAsLong();
        userPrivilegeService.cancelNotRemember(vocId, userId);
        return Result.ok();
    }

    @PostMapping("")
    public Result markNonRecite(Long vocId){
        long userId = StpKit.USER.getLoginIdAsLong();
        userPrivilegeService.notRemember(vocId, userId);
        return Result.ok();
    }
}
